#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int a[5] = {0, 1, 20, 300, 4000};
int p[5] = {0, 1, 10, 100, 1000};
int b[5] = {0, 1, 11, 111, 1111};
void solve() {
  int n;
  cin >> n;

  vector<int> digit;
  while (n) {
    digit.push_back(n % 10);
    n /= 10;
  }

  int cnt[10] = {0};
  int x = 0;
  int len = digit.size();
  rep(i, 0, len - 1) {
    // 0-9 appears in the least significant pos
    rep(j, 0, 9) cnt[j] += a[i] * digit[i];
    // 0 - d[i]-1 appears in the cur pos
    rep(j, 0, digit[i] - 1) cnt[j] += p[i + 1];
    // d[i] appears int the cur pos
    cnt[digit[i]] += x + 1;
    x += digit[i] * p[i + 1];
  }
  cnt[0] -= b[len];
  rep(i, 0, 9) cout << cnt[i] << " \n"[i == 9];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}